package com.MSB.LinkedList;

import java.util.TreeMap;

public class SortedMap {
    public static void main(String[] args) {
        TreeMap<Integer, String> treeMap = new TreeMap<>();
        treeMap.put(3,"我是3");
        treeMap.put(1,"我是1");
        treeMap.put(5,"我是5");
        treeMap.put(6,"我是6");
        treeMap.put(9,"我是9");
        treeMap.put(0,"我是0");
        treeMap.put(8,"我是8");

        System.out.println(treeMap.firstKey());
        System.out.println(treeMap.lastKey());
        System.out.println(treeMap.get(5));

        // <= 4
        System.out.println(treeMap.floorKey(4));
        // >= 4
        System.out.println(treeMap.ceilingKey(4));
    }
}
